package edu.geo.algorithm.graph;

import java.util.ArrayList;
import java.util.List;

import edu.geo.containers.geom.impl.LineSegment;

public class Arc  {

private List<Arc> successors;
private List<Arc> predeccessors;
private int id ;
private LineSegment geom ;

public Arc(int id,LineSegment geom )
{
	this.id=id;
	this.geom=geom;
	successors= new  ArrayList<Arc>();
	predeccessors=new  ArrayList<Arc>();
}
	

	public List<Arc> getSuccessor() {
		return successors;
	}


	public List<Arc> getPredeccessor() {
		return predeccessors;
	}


	public boolean isLeaf() {

		if(successors.size()==0)
		{
			return true;
		}
		
		if(predeccessors.size()==0)
		{
			return true;
		}
		return false;
	}
	
	public void AddSuccessor(Arc arc)
	{boolean isEquals= false;
		for(Arc arcSuc:successors)
		{if(arc.equals(arcSuc)) 
			isEquals=true;
		}
		if(isEquals==false)
		{
			successors.add(arc);	
		}
	}
	
	public void AddPredeccessor(Arc arc)
	{
		boolean isEquals= false;
		for(Arc arcPred:predeccessors)
		{if(arc.equals(arcPred)) 
			isEquals=true;
		}
		if(isEquals==false)
		{
			predeccessors.add(arc);	
		}
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public LineSegment getGeom() {
		return geom;
	}


	public void setGeom(LineSegment geom) {
		this.geom = geom;
	}
	

}
